package com.common.util;

import com.mark.entity.StuAnswer;
import com.mark.entity.StuOptions;
import com.paper.entity.Paper;
import com.paper.entity.Subtopics;
import com.paper.entity.Topics;

public class FilterAnswer {
	public static Paper filterPaper(Paper paper) {
		if(paper!=null){
			Paper result = paper;
			
			for(Integer i:result.getTopics().keySet()) {
				Topics topics = result.getTopics().get(i);
				for(Integer j:topics.getSubtopics().keySet()) {
					Subtopics subtopics = topics.getSubtopics().get(j);
					if(null!=subtopics.getSingle()) {
						subtopics.getSingle().setAnswer(null);
					}else if(null!=subtopics.getMultiple()) {
						subtopics.getMultiple().setAnswers(null);
					}else if(null!=subtopics.getBlank()) {
						for(Integer k:subtopics.getBlank().getBlanks().keySet()) {
							subtopics.getBlank().getBlanks().get(k).setContent(null);
						}
					}else if(null!=subtopics.getJudgment()) {
						subtopics.getJudgment().setAnswer(null);
					}else if(null!=subtopics.getExplanation()) {
						subtopics.getExplanation().setReference(null);
					}else {
						
					}
				}
			}
			
			return result;
		}else {
			return null;
		}
	}
	public static StuAnswer filterStuAnswer(StuAnswer stuAnswer) {
		if(null!=stuAnswer) {
			StuAnswer result = stuAnswer;
			for(StuOptions s:stuAnswer.getStuOptions()) {
				Subtopics subtopics = s.getSubtopics();
				if(null!=subtopics.getSingle()) {
					subtopics.getSingle().setAnswer(null);
				}else if(null!=subtopics.getMultiple()) {
					subtopics.getMultiple().setAnswers(null);
				}else if(null!=subtopics.getBlank()) {
					for(Integer k:subtopics.getBlank().getBlanks().keySet()) {
						subtopics.getBlank().getBlanks().get(k).setContent(null);
					}
				}else if(null!=subtopics.getJudgment()) {
					subtopics.getJudgment().setAnswer(null);
				}else if(null!=subtopics.getExplanation()) {
					subtopics.getExplanation().setReference(null);
				}else {
					
				}
			}
			return result;
		}else {
			return null;
		}
	}
}
